$(document).ready(function(){
    
    // Reset Password
    maintenance.reset_password(".recover_password");
});

maintenance = {

    reset_password : function(elements){
        
        $("body").on("click",elements,function(){
            var data_type = $(this).attr("data-type");
            $(this).html('<img src="/images/loaders/1d_4.gif">');
            $(this).attr("disabled",true);
            if (data_type) {
                if (data_type == "recover") {
                    var email = $('[name="email"]').val();
                    if (isValidEmailAddress(email)) {
                        
                        $.ajax({
                            type : "POST",
                            url  : "/ajax/maintenance",
                            data : {email:email,action:"reset_password"},
                            success : function(data){
                                var json_m = JSON.parse(data);
                                
                                if (json_m['notification'] == "Ok") {
                                    notify_s('Success', json_m['msg']);
                                    
                                    $(elements).html('Recover');
                                    $(elements).attr("disabled",false);
                                    $('[name="email"]').val(null);
                                }
                            }
                        })
                        
                    }else{
                        notify_e('Error', 'Need to enter number of pages in Brochure Settings.');
                        $(elements).html('Recover');
                        $(elements).attr("disabled",false);
                    }
                    
                }
            }
                
            
        });
        
    }

}

